import axios from '../utils/axios'
import api from '../api'

export function home() {
    return new Promise((resolve, reject) => {
        axios.post(api.getmenu, {}).then(res => {
            resolve(res.data)
        }).catch(err => {
            reject(err)
        })
    })
}

const data = {
    "code": 200,
    "msg": "权限查询成功",
    "data": [
        {
            "children": [
                {
                    "menuName": "采购管理",
                    "id": 11,
                    "sort": "1"
                }
            ],
            "menuName": "采购",
            "id": 1,
            "sort": "1"
        },
        {
            "children": [
                {
                    "menuName": "销售订单管理",
                    "id": 21,
                    "sort": "1"
                }
            ],
            "menuName": "销售",
            "id": 2,
            "sort": "2"
        },
        {
            "children": [
                {
                    "menuName": "入库管理",
                    "id": 31,
                    "sort": "1"
                },
                {
                    "menuName": "出库管理",
                    "id": 32,
                    "sort": "2"
                }
            ],
            "menuName": "库存",
            "id": 3,
            "sort": "3"
        },
        {
            "children": [
                {
                    "menuName": "销售订单管理",
                    "id": 41,
                    "sort": "1"
                },
                {
                    "menuName": "采购订单管理",
                    "id": 42,
                    "sort": "2"
                },
                {
                    "menuName": "退货",
                    "id": 43,
                    "sort": "3"
                }
            ],
            "menuName": "资金",
            "id": 4,
            "sort": "4"
        },
        {
            "children": [
                {
                    "menuName": "路线管理",
                    "id": 51,
                    "sort": "1"
                },
                {
                    "menuName": "销售动态",
                    "id": 52,
                    "sort": "2"
                }
            ],
            "menuName": "行为",
            "id": 5,
            "sort": "5"
        },
        {
            "children": [],
            "menuName": "报表",
            "id": 6,
            "sort": "6"
        },
        {
            "children": [
                {
                    "menuName": "基本信息",
                    "id": 71,
                    "sort": "1"
                },
                {
                    "menuName": "客户管理",
                    "id": 72,
                    "sort": "2"
                },
                {
                    "menuName": "商品管理",
                    "id": 73,
                    "sort": "3"
                },
                {
                    "menuName": "价格体系",
                    "id": 74,
                    "sort": "4"
                }
            ],
            "menuName": "系统",
            "id": 7,
            "sort": "7"
        },
        {
            "lastTime": "2022-08-19 21:25:12",
            "ip": "118.116.111.162",
            "admin": "admin",
            "dept": "管理部",
            "nowTime": "2022-08-19 21:25:32"
        }
    ]
}

const menuData = [
    {
        id: 1,
        menuName: "采购",
        children: [
            {
                id: 11,
                menuName: "采购管理",
                children: [
                    { id: 111, menuName: "采购管理", pathRoute: "cggl" },
                    { id: 112, menuName: "采购申请", pathRoute: "cgsq" }
                ]
            }
        ]
    }, {
        id: 2,
        menuName: "销售",
        children: [
            {
                id: 21,
                menuName: "订单管理",
                children: [
                    { id: 211, menuName: "订单列表", pathRoute: "ddlb" },
                    { id: 212, menuName: "添加订单", pathRoute: "tjdd" }
                ]
            }
        ]
    }, {
        id: 3,
        menuName: "库存",
        children: [
            {
                id: 31,
                menuName: "出库",
                children: [
                    { id: 311, menuName: "出库管理", pathRoute: "ckgl" },
                    { id: 312, menuName: "添加出库单", pathRoute: "tjckd" }
                ]
            }, {
                id: 32,
                menuName: "入库",
                children: [
                    { id: 321, menuName: "入库管理", pathRoute: "rkgl" },
                    { id: 322, menuName: "添加入库单", pathRoute: "tjrkd" }
                ]
            }
        ]
    }, {
        id: 4,
        menuName: "资金",
        children: [
            {
                id: 41,
                menuName: "订单管理",
                children: [
                    { id: 411, menuName: "订单列表", pathRoute: "ddlb" },
                    { id: 412, menuName: "确认收货", pathRoute: "qrsh" },
                    { id: 413, menuName: "到货提醒", pathRoute: "dhtx" },
                    { id: 414, menuName: "订单设置", pathRoute: "ddsz" }
                ]
            }, {
                id: 42,
                menuName: "退款及退货",
                children: [
                    { id: 421, menuName: "退货申请处理", pathRoute: "thsqcl" },
                    { id: 422, menuName: "退款申请处理", pathRoute: "tksqcl" },
                    { id: 423, menuName: "退货原因设置", pathRoute: "thyysz" }
                ]
            }, {
                id: 43,
                menuName: "快递单管理",
                children: [
                    { id: 431, menuName: "快递单模板", pathRoute: "kddmb" },
                    { id: 432, menuName: "自定义打印项", pathRoute: "zdydyx" },
                    { id: 433, menuName: "发货点信息管理", pathRoute: "fhdxxgl" }
                ]
            }
        ]
    }, {
        id: 5,
        menuName: "行为",
        children: [
            {
                id: 51,
                menuName: "路线管理",
                children: [
                    { id: 511, menuName: "路线管理", pathRoute: "lxgl" },
                    { id: 512, menuName: "添加路线", pathRoute: "tjlx" },
                    { id: 513, menuName: "拜访结果查询", pathRoute: "bfjgcx" },
                    { id: 514, menuName: "拜访统计", pathRoute: "bftj" },
                    { id: 515, menuName: "上传信息管理", pathRoute: "scxxgl" }
                ]
            }, {
                id: 52,
                menuName: "销售动态",
                children: [
                    { id: 521, menuName: "人员销售动态", pathRoute: "ryxxdt" },
                    { id: 522, menuName: "商品销售动态", pathRoute: "spxxdt" },
                    { id: 523, menuName: "门店销售动态", pathRoute: "mdxxdt" }
                ]
            }
        ]
    }, {
        id: 6,
        menuName: "报表",
        children: [
            {
                id: 61,
                menuName: "秒杀专区",
                children: [
                    { id: 611, menuName: "秒杀活动列表", pathRoute: "mxhdlb" },
                    { id: 612, menuName: "时间段列表", pathRoute: "sjdlb" },
                    { id: 613, menuName: "秒杀提醒通知", pathRoute: "mstxtz" }
                ]
            }, {
                id: 62,
                menuName: "优惠券管理",
                children: [
                    { id: 621, menuName: "优惠券列表", pathRoute: "yhqhl" },
                    { id: 622, menuName: "添加优惠券", pathRoute: "tjyhq" }
                ]
            }, {
                id: 63,
                menuName: "活动管理",
                children: [
                    { id: 631, menuName: "活动列表", pathRoute: "hdlb" },
                    { id: 632, menuName: "添加活动", pathRoute: "tjhd" }
                ]
            }, {
                id: 64,
                menuName: "首页推荐",
                children: [
                    { id: 641, menuName: "品牌制造商", pathRoute: "ppzzs" },
                    { id: 642, menuName: "新鲜好物", pathRoute: "xxhw" },
                    { id: 643, menuName: "人气推荐", pathRoute: "rqtj" },
                    { id: 644, menuName: "专题精选", pathRoute: "ztjx" }
                ]
            }
        ]
    }, {
        id: 7,
        menuName: "系统",
        children: [
            {
                id: 71,
                menuName: "基本资料",
                children: [
                    { id: 711, menuName: "公司信息", pathRoute: "gsxx" },
                    { id: 712, menuName: "部门管理", pathRoute: "bmgl" },
                    { id: 713, menuName: "职位管理", pathRoute: "zwgl" },
                    { id: 714, menuName: "员工管理", pathRoute: "yggl" },
                    { id: 715, menuName: "仓库管理", pathRoute: "ckgl" },
                    { id: 716, menuName: "计量单位", pathRoute: "jldw" },
                    { id: 717, menuName: "操作日志", pathRoute: "czrz" }
                ]
            }, {
                id: 72,
                menuName: "客户管理",
                children: [
                    { id: 721, menuName: "客户信息", pathRoute: "khxx" },
                    { id: 722, menuName: "客户类型", pathRoute: "khlx" },
                    { id: 723, menuName: "客户区域", pathRoute: "khqy" },
                    { id: 724, menuName: "供货厂商", pathRoute: "ghcs" }
                ]
            }, {
                id: 73,
                menuName: "商品管理",
                children: [
                    { id: 731, menuName: "品牌管理", pathRoute: "ppgl" },
                    { id: 732, menuName: "商品分类", pathRoute: "spfl" },
                    { id: 733, menuName: "商品信息维护", pathRoute: "spxxwh" },
                    { id: 734, menuName: "商品置顶", pathRoute: "spzd" }
                ]
            }, {
                id: 74,
                menuName: "价格管理",
                children: [
                    { id: 741, menuName: "价格体系设置", pathRoute: "jgtxsz" }
                ]
            }
        ]
    }
]




export function user_Login({ userName, userPwd }) {
    return new Promise((resolve, reject) => {
        axios({
            url: api.getuser, method: 'post',
            data: { username: userName, password: userPwd },
            headers: {
                "Content-Type": "multipart/form-data"
            }
        }
        ).then(res => {
            console.log("ok");
            resolve(res.data)
            // resolve(data)
        }).catch(err => {
            console.log("err", err);
            reject(err)
        })
    })
}